from selenium.webdriver.common.by import By
from base.basicFunction import *


def business_withdrawal():
    logger.info("-" * 30 + "营业撤单" + "-" * 30)
    wait_for_load((By.XPATH, '//*[@id="QryResultPart"]/div[2]/div[2]/button'))  # 点击查询按钮
    sleep(2)
    Element((By.XPATH, '//*[text()="业务变更"]')).click()  # 选择订单
    if not is_display((By.XPATH, '//div[contains(text(),"不允许做营业撤单")]/../..//button'), False):
        # Element((By.ID, 'CUST_ORDER_ID')).click()  # 选择订单
        wait_for_load((By.XPATH, '//*[@id="CSSUBMIT_BUTTON"]/span'))
        sleep(1)
        wait_for_load((By.XPATH, '//*[starts-with(text(),"恭喜")]/parent::div/parent::div/div[2]/button'))  # 点击确定
        sleep(2)
    logger.info("-" * 28 + "营业撤单完成" + "-" * 28)
